#include "TerrainType.h"

TerrainTypeManager::TerrainTypeManager()
{
	types.reserve(TERRAIN_TYPE_ID_COUNT);
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GROUND, "bare ground", 
		TCODColor(133,115,71), TCODColor(113,105,61), 219, true, false, 1.0f, 0.4f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GROUND_FROZEN, "frozen ground", 
		TCODColor(163,153,131), TCODColor(147,137,125), 177, true, false, 1.0f, 0.85f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GRASS_NORMAL, "grass", 
		TCODColor(40,117,0), TCODColor(30,105,0), 177, true, false, 1.01f, 0.5f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GRASS_LUSH, "lush grass", 
		TCODColor(0,144,0), TCODColor(0,120,0), 178, true, false, 1.1f, 0.7f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GRASS_SPARSE, "sparse grass", 
		TCODColor(69,125,0), TCODColor(50,100,0), 176, true, false, 1.005f, 0.55f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GRASS_WITHERED, "withered grass", 
		TCODColor(110,125,0), TCODColor(85,100,0), 176, true, false, 1.0f, 0.45f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GRASS_DRIED, "dried grass", 
		TCODColor(150,143,92), TCODColor(130,123,72), 176, true, false, 1.02f, 0.25f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_DIRT, "dirt", 
		TCODColor(111,100,73), TCODColor(91,80,53), 178, true, false, 1.01f, 0.5f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_ROCK_BARE, "bare rock", 
		TCODColor(133,126,110), TCODColor(112,112,100), 178, true, false, 1.0f, 0.8f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_ROCK_DIRTY, "dirt-covered rock", 
		TCODColor(127,118,98), TCODColor(111,100,90), 177, true, false, 1.0f, 0.5f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GRANITE_SMOOTH, "smooth granite floor", 
		TCODColor(105,100,90), TCODColor(100,95,85), 219, true, false, 1.0f, 0.9f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GRANITE, "granite floor", 
		TCODColor(95,90,80), TCODColor(90,85,75), 176, true, false, 1.0f, 0.85f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_GRANITE_ROUGH, "rough granite floor", 
		TCODColor(85,80,70), TCODColor(80,75,65), 177, true, false, 1.0f, 0.80f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_SNOW_SHALLOW, "shallow snow", 
		TCODColor(218,223,232), TCODColor(195,198,220), 176, true, false, 1.25f, 0.98f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_SNOW_NORMAL, "snow", 
		TCODColor(229,233,242), TCODColor(205,210,230), 176, true, false, 1.5f, 0.98f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_SNOW_DEEP, "deep snow", 
		TCODColor(238,242,248), TCODColor(220,220,240), 176, true, false, 2.0f, 0.98f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_SHALLOW_WATER, "shallow water", 
		TCODColor(102,153,255), TCODColor(98,149,240), 247, true, false, 1.7f, 0.985f)));
	types.push_back(std::make_shared<TerrainType>(
		TerrainTypeParams(TERRAIN_DEEP_WATER, "deep water", 
		TCODColor(10,102,255), TCODColor(6,88,225), 247, false, true, 1.0f, 0.985f)));
}

TerrainTypeManager::~TerrainTypeManager()
{
}

const TerrainTypePtr &TerrainTypeManager::getTerrainType(TerrainId type) const
{
	for(unsigned int i = 0; i < types.size(); i++)
	{
		if(types[i]->id == type)
			return types[i];
	}
	return nullptr;
}
